// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the TRIANGULATOR_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// TRIANGULATOR_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#ifdef BUILD_DLL
#ifdef TRIANGULATOR_EXPORTS
#define TRIANGULATOR_API __declspec(dllexport)
#else
#define TRIANGULATOR_API __declspec(dllimport)
#endif
#else
#define TRIANGULATOR_API
#endif // BUILD_DLL


#include <vector>


namespace Triangulator
{


typedef double CoordType;

struct vertex
{
	CoordType X, Y;

	vertex(CoordType x, CoordType y) : X(x), Y(y) { }
};


// V1, V2, V3 - indexes to poligon's vertices
struct triangle
{
	size_t V1;
	size_t V2;
	size_t V3;
};

// coords of vertices of polygon in clockwize direction
typedef std::vector<vertex> Polygon;

// result triangles
typedef std::vector<triangle> Triangles;


// Triangulates input polygon and returns triangles, which
// vertices defined through indexes to polygon vertices
// IMPOTANT: Points must be defined in counter clock wize order
TRIANGULATOR_API Triangles Triangulate(const Polygon& polygon);


} // namespace Triangulator
